package com.yztc.xiami_app.ui.activity.user;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yztc.xiami_app.R;
import com.yztc.xiami_app.ui.activity.MainActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FindPasswardActivity extends AppCompatActivity {

    @BindView(R.id.imageview_back_registor)
    ImageView imageviewBackRegistor;
    @BindView(R.id.imageview_back_homepage)
    ImageView imageviewBackHomepage;
    @BindView(R.id.textview_register)
    TextView textviewRegister;
    @BindView(R.id.textview_find)
    TextView textviewFind;
    @BindView(R.id.login_userName_edt)
    EditText editClean;
    @BindView(R.id.image_clean)
    ImageView imageClean;
    @BindView(R.id.activity_find_passward)
    LinearLayout activityFindPassward;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_find_passward);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        editClean.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                String phonenumber = editClean.getEditableText().toString();
                if (TextUtils.isEmpty(phonenumber)) { //当没有输入内容的时候，清空按钮不可见
                    imageClean.setVisibility(View.INVISIBLE);
                } else {
                    imageClean.setVisibility(View.VISIBLE);
                }
            }
            @Override
            public void afterTextChanged(Editable s) {
            }
        });
    }

    @OnClick({R.id.imageview_back_registor, R.id.imageview_back_homepage, R.id.image_clean})
    public void onClick(View view) {
        Intent intent = new Intent();

        switch (view.getId()) {
            case R.id.imageview_back_registor:
                intent.setClass(this,LoginActivity.class);
                startActivity(intent);
                break;
            case R.id.imageview_back_homepage:
                intent.setClass(this,MainActivity.class);
                startActivity(intent);
                break;
            case R.id.image_clean:
                editClean.setText("");
                break;
        }
    }
}
